package com.ruleengine.parser.condition;

import com.ruleengine.parser.IConditionParser;
import com.ruleengine.task.condition.ConditionType;



public class ConditionParserFactory {
    private static ConditionParserFactory factory;
    private ConditionParserFactory(){}
    
    public static ConditionParserFactory getInstance(){
        if(factory==null){
            factory = new ConditionParserFactory();
        }
        return factory;
    }
    
    /**根据条件的类型获取对应
     * 的条件解析器，解析条件
     * 节点（condition）
     * @param type 条件的类型
     * @return 对应的条件解析器
     */
    public IConditionParser getConditionParser(String type){
        if(ConditionType.DEFAULT.equals(type)){
            //default条件解析器
            return new DefaultConditionParser();
        }
        throw new RuntimeException("no support condition parser type :" + type);
    }
}
